#! /bin/sh

get_bicep() {
    # repo="radius-project/bicep"
    # file_name="rad-bicep-linux-x64"

    repo="Azure/bicep"
    file_name="bicep-linux-x64"

    bicep_version=$(curl -s https://api.github.com/repos/${repo}/tags | jq -r '.[0].name')
    echo "${bicep_version}"
    cli="rad-bicep"
    bin_path="/home/youling/.rad/bin/"
    sudo rm -rf ${bin_path}/${cli}
    wget https://ghproxy.net/https://github.com/${repo}/releases/download/${bicep_version}/${file_name}
    # tar -zxvf ${file_name}
    mv ${file_name} ${cli}
    chmod +x ${cli}
    sudo mv ${cli} ${bin_path}
    # rm -rf LICENSE README.md ${file_name}
}

get_bicep
